<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="" prop="productNo">
        <el-input
          v-model="queryParams.productNo"
          placeholder="商品款式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="" prop="salePrice">
        <el-input v-model="queryParams.salePrice" placeholder="日常价" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="customerPicture">
        <el-input v-model="queryParams.customerPicture" placeholder="主图" clearable @keyup.enter.native="handleQuery" />
      </el-form-item> -->

      <el-form-item label="" prop="debutChannel">
        <el-input
          v-model="queryParams.debutChannel"
          placeholder="开播渠道"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="anchor">
        <el-input
          v-model="queryParams.anchor"
          placeholder="主播"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="" prop="livePrice">
        <el-input v-model="queryParams.livePrice" placeholder="直播价格" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="commission">
        <el-input v-model="queryParams.commission" placeholder="佣金" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="discount">
        <el-input v-model="queryParams.discount" placeholder="折扣" clearable @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <!-- <el-form-item label="" prop="insuredTime">
        <el-date-picker clearable v-model="queryParams.insuredTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择保价时间">
        </el-date-picker>
      </el-form-item> -->
      <el-form-item label="" prop="firstLevelColumn">
        <!-- <el-input v-model="queryParams.firstLevelColumn" placeholder="请输入一级栏目" clearable
          @keyup.enter.native="handleQuery" /> -->
        <el-select
          v-model="queryParams.firstLevelColumn"
          placeholder="请选择一级类目"
          clearable
        >
          <el-option
            v-for="dict in dict.type.sys_product_pl"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="debutTimeStart">
        <el-date-picker
          clearable
          v-model="queryParams.debutTimeStart"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="开播日期开始"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="" prop="debutTimeEnd">
        <el-date-picker
          clearable
          v-model="queryParams.debutTimeEnd"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="开播日期结束"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="是否保价" prop="isInsured">
        <el-radio-group
          v-model="queryParams.isInsured"
          size="small"
          @change="changeTheme"
          fill="#66b1ff"
        >
          <el-radio :label="'保价'">保价</el-radio>
          <el-radio :label="'无'">无</el-radio>
          <el-radio :label="null">所有</el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['product:price:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['product:price:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['product:price:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['product:price:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-upload" @click="daoru"
          >导入</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-plus" @click="chatVFU"
          >批量新增</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <div ref="tableDom">
      <el-table
        :maxHeight="priceList.length ? tableHeight : 'auto'"
        v-loading="loading"
        :data="priceList"
        @selection-change="handleSelectionChange"
        :row-style="{ height: '100px' }"
        border
        id="bootstrap‐table"
        @row-dblclick="t"
      >
        <el-table-column type="selection" width="55" align="center" />
        <!-- <el-table-column label="ID" align="center" prop="id" /> -->
        <el-table-column
          :label="'一级类目'"
          align="center"
          prop="firstLevelColumn"
        />
        <el-table-column label="商品款式" align="center" prop="productNo" />

        <el-table-column :label="'主图'" align="center" prop="customerPicture">
          <template #default="scope">
            <image-preview
              :src="scope.row.customerPicture"
              :width="80"
              :height="80"
            />
            <!-- <el-popover
              effect="light"
              trigger="click"
              placement="right"
              width="auto"
              v-show="scope.row.customerPicture"
            >
              <template #default>
                <img
                  :src="pjtUrl + scope.row.customerPicture"
                  style="width: 400px; height: 300px; object-fit: contain"
                />
              </template>
              <template #reference>
                <img
                  :src="pjtUrl + scope.row.customerPicture"
                  style="width: 80px; height: 80px; object-fit: contain"
                />
              </template>
            </el-popover> -->
          </template>
        </el-table-column>
        <el-table-column
          label="开播日期"
          align="center"
          prop="debutTime"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.debutTime, "{y}-{m}-{d}") }}</span>
          </template>
        </el-table-column>
        <el-table-column label="开播渠道" align="center" prop="debutChannel" />
        <el-table-column label="主播" align="center" prop="anchor" />
        <el-table-column label="日常价" align="center" prop="salePrice" />
        <el-table-column label="直播价格" align="center" prop="livePrice" />
        <el-table-column label="佣金" align="center" prop="commission" />
        <el-table-column label="折扣" align="center" prop="discount" />
        <el-table-column
          label="保价时间"
          align="center"
          prop="insuredTime"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.insuredTime, "{y}-{m}-{d}") }}</span>
          </template>
        </el-table-column>
        <el-table-column label="备注" align="center" prop="remark" />
        <el-table-column label="是否保价" align="center" prop="isInsured" />
        <!-- <el-table-column label="逻辑删除;0=未删除；1=已删除" align="center" prop="isDelete" /> -->
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['product:price:edit']"
              >修改</el-button
            >
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['product:price:remove']"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改上新渠道价格保护对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="商品款式" prop="productNo">
          <!-- <el-input v-model="form.productNo" placeholder="商品款式" /> -->
          <el-select
            v-model="form.productNo"
            clearable
            filterable
            remote
            :remote-method="getDatas"
            :loading="loading"
            placeholder="请选择商品款式"
          >
            <el-option
              v-for="item in options"
              :key="item"
              :label="item"
              :value="item"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="日常价" prop="salePrice">
          <el-input v-model="form.salePrice" placeholder="日常价" />
        </el-form-item>
        <el-form-item label="主图" prop="customerPicture">
          <el-input v-model="form.customerPicture" placeholder="主图" />
        </el-form-item> -->
        <el-form-item label="开播日期" prop="debutTime">
          <el-date-picker
            clearable
            v-model="form.debutTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择开播日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="开播渠道" prop="debutChannel">
          <el-input v-model="form.debutChannel" placeholder="开播渠道" />
        </el-form-item>
        <el-form-item label="主播" prop="anchor">
          <el-input v-model="form.anchor" placeholder="主播" />
        </el-form-item>
        <el-form-item label="直播价格" prop="livePrice">
          <el-input v-model="form.livePrice" placeholder="直播价格" />
        </el-form-item>
        <el-form-item label="佣金" prop="commission">
          <el-input v-model="form.commission" placeholder="佣金" />
        </el-form-item>
        <!-- <el-form-item label="折扣" prop="discount">
          <el-input v-model="form.discount" placeholder="折扣" />
        </el-form-item> -->
        <el-form-item label="保价时间" prop="insuredTime">
          <el-date-picker
            clearable
            v-model="form.insuredTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择保价时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="备注" />
        </el-form-item>
        <!-- <el-form-item label="是否保价" prop="isInsured">
          <el-input v-model="form.isInsured" placeholder="是否保价" />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改产品二级信息对话框 :on-change="handleChange"-->
    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      width="500px"
      append-to-body
      v-if="dialogVisible"
    >
      <el-upload
        :action="Upload.url"
        :headers="Upload.headers"
        :limit="limit"
        :on-exceed="handleExceed"
        :on-success="handlePictureSuccessDaoru"
        :before-upload="beforeAvatarUpload"
        :on-preview="handlePictureCardPreview"
        :file-list="files"
        :on-change="changeFile1"
      >
        <el-button size="small" type="primary">导入文件</el-button>
        <!-- <i class="el-icon-plus"></i> -->
      </el-upload>
    </el-dialog>

    <!-- 内部寄样 -->
    <el-dialog
      :visible.sync="VisibleVFU"
      append-to-body
      title="批量新增"
      width="600px"
      v-if="VisibleVFU"
    >
      <el-form
        ref="formVFU"
        :model="formVFU"
        :rules="rules"
        label-width="110px"
        :inline="true"
      >
        <!-- <el-form-item label="请选择收件地址" prop="address">
          <el-select v-model="formVFU.id">
            <el-option v-for="item in optionsContact" :key="item.id" :label="item.address" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="是否归还" prop="isReturn">
          <el-input v-model="formVFU.isReturn" placeholder="是否归还" />
        </el-form-item>
        <el-form-item label="快递公司" prop="expressCompany">
          <el-input v-model="formVFU.expressCompany" placeholder="快递公司" />
        </el-form-item> -->
        <el-row v-for="(noticItem, index) in fVFU.colorProperty" :key="index">
          <el-col>
            <el-form-item label="商品款式" prop="colorProperty">
              <!-- <el-input v-model="noticItem.value" placeholder="请输入颜色属性" /> -->
              <el-select
                v-model="noticItem.value"
                clearable
                filterable
                remote
                :remote-method="getDatas"
                :loading="loading"
                placeholder="商品款式"
              >
                <el-option
                  v-for="item in options"
                  :key="item"
                  :label="item"
                  :value="item"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-button type="primary" size="mini" @click="addVFU"
              >新增</el-button
            >
            <el-button size="mini" @click.prevent="removeVFU(noticItem)"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-form-item label="开播日期" prop="debutTime">
          <el-date-picker
            clearable
            v-model="formVFU.debutTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择开播日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="开播渠道" prop="debutChannel">
          <el-input v-model="formVFU.debutChannel" placeholder="开播渠道" />
        </el-form-item>
        <el-form-item label="主播" prop="anchor">
          <el-input v-model="formVFU.anchor" placeholder="主播" />
        </el-form-item>
        <el-form-item label="直播价格" prop="livePrice">
          <el-input v-model="formVFU.livePrice" placeholder="直播价格" />
        </el-form-item>
        <el-form-item label="佣金" prop="commission">
          <el-input v-model="formVFU.commission" placeholder="佣金" />
        </el-form-item>
        <!-- <el-form-item label="折扣" prop="discount">
          <el-input v-model="form.discount" placeholder="折扣" />
        </el-form-item> -->
        <el-form-item label="保价时间" prop="insuredTime">
          <el-date-picker
            clearable
            v-model="formVFU.insuredTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择保价时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="formVFU.remark" placeholder="备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 50px">
        <el-button type="primary" @click="submitVFU">确 定</el-button>
        <!-- <el-button @click="canNew">取 消</el-button> -->
        <!-- <el-button @click="addVFU">新增</el-button> -->
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listTemplate,
  getTemplate,
  delTemplate,
  addTemplate,
  updateTemplate,
  addTemplateAndSecondry,
  addProNoColorSize,
  productNoLike,
} from "@/api/product/template";
import {
  listPrice,
  getPrice,
  delPrice,
  addPrice,
  updatePrice,
  addBatch,
} from "@/api/edit/price";
//--------导入token
import { getToken } from "@/utils/auth";
export default {
  name: "Price",
  dicts: [
    "sys_product_qudao",
    "sys_product_size",
    "sys_product_design",
    "sys_product_scene",
    "sys_product_coder",
    "sys_product_yf",
    "sys_product_cycle",
    "sys_product_pl",
  ],
  data() {
    return {
      formVFU: {},
      VisibleVFU: false,
      fVFU: {
        colorProperty: [{ value: "" }],
      },

      tableHeight: "",
      options: [], // 选项，从后端传递过来
      // 图片数量限制
      limit: 2,
      //产品导入
      dialogVisible: false,
      files: [],
      Upload: {
        // 设置上传的请求头部
        headers: {
          Authorization: "Bearer " + getToken(),
        },
        // 图片上传的方法地址:
        url: process.env.VUE_APP_BASE_API + "/product/price/importChannelPrice",
      },
      pjtUrl: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 上新渠道价格保护表格数据
      priceList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        productNo: null,
        salePrice: null,
        customerPicture: null,
        debutTime: null,
        debutChannel: null,
        anchor: null,
        livePrice: null,
        commission: null,
        discount: null,
        insuredTime: null,
        isInsured: null,
        isDelete: null,
        firstLevelColumn: null,
        debutTimeEnd: null,
        debutTimeStart: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  mounted() {
    var _this = this;
    this.resizeTable();
    window.onresize = function () {
      _this.resizeTable();
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 删除
    removeVFU(item) {
      var index = this.fVFU.colorProperty.indexOf(item);
      if (index == "0") {
        // 还有一个的时候提示不能删除
        this.$message({
          message: "不能删除了",
          type: "error",
        });
        return false;
      }
      if (index !== -1 && index !== "0") {
        this.fVFU.colorProperty.splice(index, 1);
      }
    },
    // 表单新增
    addVFU() {
      this.fVFU.colorProperty.push({
        value: "",
        // key: Date.now()+,
      });
    },
    //el-dialog关闭
    // handleClose() {
    //   // Object.assign(this.$data, this.$options.data())
    //   this.$data = this.$options.data();
    //   this.
    //   this.VisibleVFU = false;
    // },
    //批量添加
    chatVFU(row) {
      this.VisibleVFU = true;

      // if (this.ids.length > 1 || this.ids.length == 0) {
      //   this.$modal.msgError('请选择一个指定达人信息！')
      //   return
      // }
      // listContact({ sampleTalentInfoId: this.ids[0] }).then(res => {
      //   if (res.rows.length == 0) {
      //     this.$modal.msgError("请添加达人收件信息！");
      //     return

      //   } else if (res.rows.length > 0) {
      //     this.optionsContact = res.rows
      //     console.log(JSON.stringify(this.optionsContact));
      //     this.VisibleVFU = true;
      //   }
      // })
    },
    //批量添加
    submitVFU() {
      // this.fLive.sampleTalentInfoId = this.ids[0]
      let label = [];
      this.fVFU.colorProperty.forEach((item) => {
        //判断条件 货号不能为空
        if (label.indexOf(item.value) == -1 && item.value !== "") {
          label.push({ productNo: item.value, ...this.formVFU });
        }
      });
      if (label.length == 0) {
        this.$modal.msgError("请选择至少一个合作款式！");
        return;
      }
      this.formVFU = label;
      // console.log(JSON.stringify(this.fLive.sampleTalentTemplateList));
      console.log(JSON.stringify(this.formVFU));
      // return
      this.$refs["formVFU"].validate((valid) => {
        if (valid) {
          addBatch(this.formVFU).then((response) => {
            if (response.code == 200) {
              this.$modal.msgSuccess("新增成功");

              this.getList();
              // this.fAdd.colorProperty = []
              this.VisibleVFU = false;
              // this.$router.push({ path: '/sample/sampleApply', query: { id: this.ids[0] } })
              Object.assign(this.$data, this.$options.data());
            } else {
              this.$modal.msgError("新增失败！");
              Object.assign(this.$data, this.$options.data());
              this.VisibleVFU = false;
              this.getList();
            }
          });
        }
      });
    },

    changeTheme(val) {
      console.log(val);
      this.getList({ isInsured: val });
    },
    /* 获取选项列表 */
    getDatas(key) {
      console.log(JSON.stringify(key));
      this.loading = true;
      // return
      productNoLike(key).then((res) => {
        this.loading = false;
        this.options = res.data;
        console.log(JSON.stringify(this.options));
      });
    },
    //点击某一行
    t(row, column, cell, event) {
      console.log(row, column, cell, event);
      this.handleUpdate(row);
    },
    /** 查询上新渠道价格保护列表 */
    getList() {
      this.loading = true;
      listPrice(this.queryParams).then((response) => {
        this.priceList = response.rows;
        console.log(JSON.stringify(this.priceList));
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        productNo: null,
        salePrice: null,
        customerPicture: null,
        debutTime: null,
        debutChannel: null,
        anchor: null,
        livePrice: null,
        commission: null,
        discount: null,
        insuredTime: null,
        remark: null,
        isInsured: null,
        isDelete: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        debutTimeEnd: null,
        debutTimeStart: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加活动价格";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getPrice(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改活动价格";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updatePrice(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPrice(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除活动价格编号为"' + ids + '"的数据项？')
        .then(function () {
          return delPrice(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "product/price/export",
        {
          ...this.queryParams,
        },
        `price_${new Date().getTime()}.xlsx`
      );
    },
    //图片上传前的相关判断
    beforeAvatarUpload(file) {
      // const isJPG = file.type === 'image/jpeg' || file.type == 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 20;
      // if (!isJPG) {
      //   this.$message.error('上传头像图片只能是 JPG/PNG 格式!');
      // }
      if (!isLt2M) {
        this.$message.error("上传文件大小不能超过 20MB!");
      }
      return isLt2M;
    },
    //图片预览
    handlePictureCardPreview(file) {
      // this.picUrl = file.url
      // this.imageUrl = file.url;
      // this.dialogVisible = true;
    },

    //部门文件导入修改打开
    daoru() {
      this.dialogVisible = true;
    },
    handlePictureSuccessDaoru(res, file) {
      // = file.response.url;
      // console.log(JSON.stringify(this.file));
      if (res.code == 200) {
        this.$modal.msgSuccess("导入成功");

        this.dialogVisible = false;
        if (res.msg == "操作成功") {
          this.$modal.msgSuccess("导入成功");
        } else {
          this.$modal.msgError(res.msg);
        }
        this.getList();
        return true;
      } else {
        this.$modal.msgError(res.msg);
        this.dialogVisible = true;
        // this.$message.msgError('该颜色未在字典定义')
        return;
      }
    },

    // 文件个数超出
    handleExceed() {
      this.$modal.msgError(`上传链接LOGO图片数量不能超过 ${this.limit} 个!`);
    },
    // 上传文件让第二次覆盖第一的文件
    changeFile1(file, fileList) {
      if (fileList.length > 1) {
        this.files = fileList.slice(-1);

        // this.fileList = [fileList[fileList.length - 1]]//这一步，是 展示最后一次选择文件
      }
      // this.fileSpecial = fileList;
    },
    // table自动高度
    returnTableHeight(ref, bottomOffset) {
      let height = null;
      height =
        window.innerHeight - ref.getBoundingClientRect().top - bottomOffset;
      return height;
    },

    resizeTable() {
      this.$nextTick(() => {
        this.tableHeight = this.returnTableHeight(this.$refs.tableDom, 100);
      }, 0);
    },
  },
};
</script>
